import { ADD, SUB, ADDASYNC } from './constants'
export default function (state = { count: 0, xxx: '哈哈' }, action) {
  switch (action.type) {
    case ADD:
      return {
        ...state,
        count: state.count + action.payload,
      }
    case SUB:
      return {
        ...state,
        count: state.count - action.payload,
      }

    // case ADDASYNC:
    //   setTimeout(() => {
    //     return {
    //       ...state,
    //       count: state.count + action.payload,
    //     }
    //   }, 2000)

    default:
      return state
  }
}
